<?php
session_start();
/*
 * Session variables:
 * $_SESSION['database'] [string] = database name of the current tutorial centre
 * $_SESSION['type'] [string] = user type of the logged in user
 * $_SESSION['authorised'] [boolean] = whether or not the current user is logged in
 * $_SESSION['user'] [string] = the username/ email of the logged in user
 */
if (isset($_SESSION['authorised']) && $_SESSION['authorised'] == true) {
	if (isset($_SESSION['type'])) {
		if ($_SESSION['type'] == 'administrator') {
			?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
	function setOptions(chosen) 
	{
		var selbox = document.myform.birthday;
		selbox.options.length = 0;
		
		if (chosen == "Jan" || chosen == "Mar" || chosen == "May" || chosen == "Jul" || chosen == "Aug" || chosen == "Oct" || chosen == "Dec")
		{
		  <?php 
		  for($i=1; $i < 32; $i++)
		  {
		  	print ("selbox.options[selbox.options.length] = new Option($i,$i);\n");
		  }
		  ?>
		}
		else if (chosen == "Feb")
		{
		  <?php 
		  for($i=1; $i < 29; $i++)
		  {
		  	print ("selbox.options[selbox.options.length] = new Option($i,$i);\n");
		  }
		  ?>
		}
		else
		{
		  <?php 
		  for($i=1; $i < 31; $i++)
		  {
		  	print ("selbox.options[selbox.options.length] = new Option($i,$i);\n");
		  }
		  ?>
		}
	}
			</script>
<script type="text/javascript">
                        function checkPasswordMatch() {            
                            var pass1 = document.getElementById('pass1');
                            var pass2 = document.getElementById('pass2');
                            var message = document.getElementById('passwordmessage');

                            if(pass1.value == pass2.value) {
                                pass2.style.backgroundColor = "#66cc66";
                                message.style.color = "#66cc66";
                                message.innerHTML = "Passwords Match!";
                            } else {
                                pass2.style.backgroundColor = "#ff6666";
                                message.style.color = "#ff6666";
                                message.innerHTML = "Passwords Do Not Match!";
                            }
                        }
                    </script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Account Creation</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<style>
.nav {
	width: 210px;
	height: auto;
	border: thin solid #09C;
	margin-left: 10px;
	text-align: center;
}

.mainline {
	width: 712px;
	height: auto;
	text-align: center;
}
</style>
</head>

<center>
	<body bgcolor="#FFFFFF">
		<div id="wrapper">
			<div id="header">
				<h1></h1>
			</div>

			<div id="header2">
				<h3></h3>
			</div>


			<div id="nav">
				<?php include 'admin_navigation.php';?>
			</div>

			<div id="mainline">
				<h4>Create an Account</h4>
				<div id="body">
					<form enctype="multipart/form-data" name="myform"
						action="admin_creating_account.php" method="post">
						<table width="712" cellpadding="2" class="infotable" align="left">
							<tr align="left">
								<th height="42" scope="row">First Name:</th>
								<td><input type="text" size="50" maxlength="100" id="first_name"
									name="first_name" />
								</td>
							</tr>
							<tr align="left">
								<th height="42" scope="row">Middle Name:</th>
								<td><input type="text" size="50" maxlength="100"
									id="middle_name" name="middle_name" />
								</td>
							</tr>
							<tr align="left">
								<th height="42" scope="row">Last Name:</th>
								<td><input type="text" size="50" maxlength="100" id="last_name"
									name="last_name" />
								</td>
							</tr>
							<tr align="left">
								<th height="42" scope="row">Email:</th>
								<td><input type="text" size="50" maxlength="100" id="email"
									name="email" />
								</td>
							</tr>

							<tr align="left">
								<th height="42" scope="row">Password:</th>
								<td><input type="password" size="30" maxlength="30" id="pass1"
									name="pass1" /></td>
							</tr>
							<tr align="left">
								<th height="42" scope="row">Repeat Password:</th>
								<td><input type="password" size="30" maxlength="30" id="pass2"
									name="pass2" onkeyup="checkPasswordMatch(); return false;" /></td>
							</tr>
							<tr align="left">
								<th height="42" scope="row">Account Type:</th>
								<td><select name="accType">
										<option value="student">Student</option>
										<option value="parent">Parent</option>
										<option value="tutor">Tutor</option>
								</select>
								</td>
							</tr>
							<tr height="40">
								<th align="left">Birthday:</th>
								<td><select name="birthmonth"
									onchange="setOptions(document.myform.birthmonth.options[document.myform.birthmonth.selectedIndex].value);">
										<option value="" selected="selected">MONTH</option>
										<option value="Jan">January</option>
										<option value="Feb">Febuary</option>
										<option value="Mar">March</option>
										<option value="Apr">April</option>
										<option value="May">May</option>
										<option value="Jun">June</option>
										<option value="Jul">July</option>
										<option value="Aug">August</option>
										<option value="Sep">September</option>
										<option value="Oct">October</option>
										<option value="Nov">November</option>
										<option value="Dec">December</option>
								</select> <select name="birthday">
										<option value="" selected="selected">DAY</option>

								</select> <select name="birthyear">
								<?php
								for($i=1930; $i<2001; $i++)
								{
									echo "<option value=$i>$i</option>";
								}
								?>
								</select>
								</td>
							</tr>
							<tr height="40">
								<th align="left">Gender:</th>
								<td><select name="gender">
										<option value="MALE">Male</option>
										<option value="FEMALE">Female</option>
								
								</td>
							</tr>
							<tr align="left">
								<th height="42" scope="row">Contact Number:</th>
								<td><input type="text" size="50" maxlength="100"
									id="contact_num" name="contact_num" />
								</td>
							</tr>
							<tr align="left">
								<th height="42" scope="row">Street Address 1:</th>
								<td><input type="text" size="50" maxlength="100"
									id="street_add1" name="street_add1" />
								</td>
							</tr>
							<tr align="left">
								<th height="42" scope="row">Street Address 2:</th>
								<td><input type="text" size="50" maxlength="100"
									id="street_add2" name="street_add2" />
								</td>
							</tr>
							<tr align="left">
								<th height="42" scope="row">City Address:</th>
								<td><input type="text" size="50" maxlength="100" id="city_add"
									name="city_add" />
								</td>
							</tr>
							<tr align="left">
								<td></td>
								<td><input type="submit" value="Submit" /></td>
							</tr>
						</table>
					</form>

					<p align="justify">
						<br />
					</p>
				</div>

				<br class="clearfloat" /> <br />

			</div>
			<div id="footer">
				<p align="center">
					Tutorial Business Manager: info@tbms.com <br />Credits/Engineers:
					Aquino, Chloebelle; Dela Cruz, Roy Erwin; Maliwanag, Ranyel Bryan;
					Manzano, Audrey Ann; Ng, Sheila Regine<br /> <br />copyright 2011
				</p>
			</div>
		</div>
	</body>
</center>
</html>
								<?php
		} elseif ($_SESSION['type'] == 'student') {
			header('Location: student_index.php');
			exit();
		} elseif ($_SESSION['type'] == 'tutor') {
			header('Location: tutor_index.php');
			exit();
		} elseif ($_SESSION['type'] == 'parent') {
			header('Location: parent_index.php');
			exit();
		}
	}
} else {
	header('Location: index.php');
}
?>
